#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
  int maximumBags(vector<int> &capacity, vector<int> &rocks, int m)
  {
    int n = rocks.size();
    vector<int> ava(n);
    for (int i = 0; i < n; i++)
      ava[i] = capacity[i] - rocks[i];
    sort(ava.begin(), ava.end());
    int i = 0;
    while (i < n && m >= ava[i])
    {
      m -= ava[i++];
    }
    return i;
  }
};
int main()
{
  Solution s;

  return 0;
}
